package com.dlx.order.controller.api;

import com.dlx.common.result.Result;
import com.dlx.model.activity.RechargeActivity;
import com.dlx.order.service.RechargeOrderInfoService;
import com.dlx.vo.order.RechargeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <h3>smms_parent</h3>
 *
 * @author nglon
 * @description <p>充值订单API接口类</p>
 * @date 2021-11-16 19:56
 **/
@RestController
@Api("充值订单接口")
@RequestMapping("/api/order/rechargeOrder")
public class RechargeOrderInfoApiController {

    @Autowired
    private RechargeOrderInfoService rechargeOrderInfoService;

    @ApiOperation("创建充值订单")
    @PostMapping("auth/recharge")
    public Result recharge(@RequestBody RechargeVo rechargeVo){
        Boolean isRecharge = this.rechargeOrderInfoService.recharge(rechargeVo);
        return isRecharge ? Result.ok("充值成功") : Result.fail("充值失败");
    }

    @ApiModelProperty("获得充值活动信息")
    @GetMapping("getRechargeActivityInfo")
    public Result getRechargeActivityInfo(){
        RechargeActivity rechargeActivityInfo = this.rechargeOrderInfoService.getRechargeActivityInfo();
        return Result.ok(rechargeActivityInfo);
    }

}
